package com.j2data.spike.utils;

import org.thymeleaf.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 手机号码格式校验工具类
 *
 * @author j2data
 * @since 2022-02-18
 */
public class ValidatorUtil {
    private static final Pattern mobile_PATTERN = Pattern.compile("[1]([3-9])[0-9]{9}$");

    /**
     * 校验手机号码格式是否正确
     *
     * @param mobile
     * @return
     */
    public static boolean isMobile(String mobile) {
        if (StringUtils.isEmpty(mobile)) {
            return false;
        }
        Matcher matcher = mobile_PATTERN.matcher(mobile);
        return matcher.matches();
    }
}
